#include "VCatagoryEffect.h"
#include "VCatagoryEffectRow.h"
#include "VCatagoryEffectItem.h"
#include "VCatagoryUi.h"
#include "common.h"

VCatagoryEffect::VCatagoryEffect(void)
{
    init();
}

VCatagoryEffect::~VCatagoryEffect(void)
{
}

void VCatagoryEffect::init()
{
    int i;
    VCatagoryEffectRow* row;

    for (i = 0; i != line_count; ++i)
    {
        row = new VCatagoryEffectRow;
        row->setPrivateData(new int(i));
        row->move(x_start, y_start + y_margin * i);
        row->init();

        insert(row);
    }
}

void VCatagoryEffect::expand()
{
    size_t i;
    VCatagoryEffectRow* row;

    for (i = 0; i != _children->size(); ++i)
    {
        row = (VCatagoryEffectRow*)(_children->at(i));
        row->expand();
    }
}

void VCatagoryEffect::clickEventHandle(VCatagoryEffectRow* row, VCatagoryEffectItem* item)
{
    int rowid, itemid;
    rowid = *(int*)row->privateData();
    itemid = *(int*)item->privateData();

    ((VCatagoryUi*)_parent)->eventHandle(rowid * row->item_count + itemid);
}